import type { ProColumnsTypes } from '@vh-admin/pro-components/lib/t-table-custom/types';
export const columnsFn = (dictionaries: any): ProColumnsTypes<any>[] => {
  return [
    //搜索
    {
      title: '账号',
      dataIndex: 'account',
      fieldProps: { maxLength: 20 },
      hideInForm: true,
      hideInTable: true,
    },
    {
      title: '角色',
      dataIndex: 'role_id',
      valueType: 'select',
      fieldProps: { options: dictionaries.AdminRole.self },
      hideInForm: true,
      hideInTable: true,
    },
    {
      title: '状态',
      dataIndex: 'status',
      valueType: 'select',
      fieldProps: {
        options: dictionaries.AdminUser.status,
      },
      hideInForm: true,
      hideInTable: true,
    },
    {
      title: '电话',
      dataIndex: 'phone',
      fieldProps: { maxLength: 11 },
      hideInForm: true,
      hideInTable: true,
    },
    //表格
    {
      title: '名称',
      dataIndex: 'name',
      search: false,
      hideInForm: true,
    },
    {
      title: '头像',
      dataIndex: 'headimg',
      valueType: 'image',
      search: false,
      hideInForm: true,
    },
    {
      title: '角色',
      dataIndex: 'role_name',
      search: false,
      hideInForm: true,
    },
    {
      title: '账号',
      dataIndex: 'account',
      ellipsis: true,
      copyable: true,
      search: false,
      hideInForm: true,
    },
    {
      title: '状态',
      dataIndex: 'status',
      valueType: 'select',
      fieldProps: {
        options: dictionaries.AdminUser.status,
      },
      businessStyle: { type: 'tag' },
      search: false,
      hideInForm: true,
    },
    {
      title: '电话',
      dataIndex: 'phone',
      search: false,
      hideInForm: true,
    },
    {
      title: '最后登录时间',
      dataIndex: 'last_login_at',
      valueType: 'dateTime',
      width: 200,
      sorter: true,
      search: false,
      hideInForm: true,
      hideInSearch: true,
    },
    {
      title: '创建时间',
      dataIndex: 'created_at',
      valueType: 'dateTime',
      width: 200,
      sorter: true,
      search: false,
      hideInForm: true,
      hideInSearch: true,
    },
    //表单
    {
      title: '名称',
      dataIndex: 'name',
      formGroup: 1,
      search: false,
      hideInTable: true,
      fieldProps: { maxLength: 20 },
      formItemProps: { rules: [{ required: true }] },
    },
    {
      title: '账号',
      dataIndex: 'account',
      formGroup: 1,
      search: false,
      hideInTable: true,
      fieldProps: { maxLength: 20 },
      formItemProps: { rules: [{ required: true }, { min: 4 }] },
    },
    {
      title: '角色',
      dataIndex: 'role_id',
      valueType: 'select',
      fieldProps: { options: dictionaries.AdminRole.self },
      formGroup: 2,
      formItemProps: { rules: [{ required: true }] },
      search: false,
      hideInTable: true,
    },
    {
      title: '状态',
      dataIndex: 'status',
      valueType: 'select',
      fieldProps: {
        options: dictionaries.AdminUser.status,
      },
      initialValue: 1,
      formGroup: 2,
      formItemProps: { rules: [{ required: true }] },
      search: false,
      hideInTable: true,
    },
    {
      title: '电话',
      dataIndex: 'phone',
      formGroup: 3,
      fieldProps: { maxLength: 11 },
      search: false,
      hideInTable: true,
    },
    {
      title: '密码',
      dataIndex: 'password',
      valueType: 'password',
      tip: '新增不填写默认(123456)、编辑不填写则不修改.',
      formGroup: 3,
      search: false,
      hideInTable: true,
      hideInSearch: true,
      fieldProps: { maxLength: 20 },
      formItemProps: { rules: [{ min: 4 }] },
    },
    {
      title: '头像',
      dataIndex: 'headimg',
      valueType: 'UploadCustom',
      formGroup: 4,
      search: false,
      hideInTable: true,
      fieldProps: {
        path: 'user_head',
        maxCount: 1,
        format: ['jpg', 'jpeg', 'png'],
        size: 2000,
        listType: 'picture-card',
        imgCrop: true,
      },
    },
  ];
};
